www.gusucode.com > 24Beta 虚拟主机版 1.0.0 Beta源码程序 > 24Beta 虚拟主机版 1.0.0 Beta源码程序/24Beta-1.0.0-vhost/protected/modules/admin/controllers/AjaxController.php
<?php class AjaxController extends CController { public function init() { if (!app()->request->isAjaxRequest || !app()->request->isPostRequest) { echo '非法请求'; exit; } } public function actionPostAuth() { $aid = $_GET['aid']; if (empty($aid) || !is_numeric($aid)) { $data['result'] = -2; $data['message'] = '非法请求'; echo json_encode($data); exit; } $post = Post::model()->findByPk($aid); $post->isauth = (int)abs($post->isauth - 1); $result = $post->update(); $data['result'] = $result ? $post->isauth : -1; $data['message'] = $result ? '文章已经通过审核' : '文章没有通过审核'; echo json_encode($data); } public function actionPostShow() { $aid = $_GET['aid']; if (empty($aid) || !is_numeric($aid)) { $data['result'] = -2; $data['message'] = '非法请求'; exit; } $post = Post::model()->findByPk($aid); $post->isshow = (int)abs($post->isshow - 1); $result = $post->update(); $data['result'] = $result ? $post->isshow : -1; $data['message'] = $result ? '文章状态已经更改为可显示' : '文章已经被隐藏'; echo json_encode($data); } public function actionPostLock() { $aid = $_GET['aid']; if (empty($aid) || !is_numeric($aid)) { $data['result'] = -2; $data['message'] = '非法请求'; exit; } $post = Post::model()->findByPk($aid); $post->allow_comment = (int)abs($post->allow_comment - 1); $result = $post->update(); $data['result'] = $result ? $post->allow_comment : -1; $data['message'] = $result ? '文章已经锁定,不允许评论' : '文章已经解锁'; echo json_encode($data); } public function actionPostRecommend() { $aid = $_GET['aid']; if (empty($aid) || !is_numeric($aid)) { $data['result'] = -2; $data['message'] = '非法请求'; exit; } $post = Post::model()->findByPk($aid); $post->editor_recommend = (int)abs($post->editor_recommend - 1); $result = $post->update(); $data['result'] = $result ? $post->editor_recommend : -1; $data['message'] = $result ? '推荐文章成功' : '推荐文章失败'; echo json_encode($data); } public function actionPostHot() { $aid = $_GET['aid']; if (empty($aid) || !is_numeric($aid)) { $data['result'] = -2; $data['message'] = '非法请求'; exit; } $post = Post::model()->findByPk($aid); $post->ishot = (int)abs($post->ishot - 1); $result = $post->update(); $data['result'] = $result ? $post->ishot : 0; $data['message'] = $result ? '文章已经被添加为头条' : '更新文章头条失败'; echo json_encode($data); } public function actionPostTop() { $aid = $_GET['aid']; if (empty($aid) || !is_numeric($aid)) { $data['result'] = -2; $data['message'] = '非法请求'; exit; } $post = Post::model()->findByPk($aid); $post->istop = (int)abs($post->istop - 1); $result = $post->update(); $data['result'] = $result ? $post->istop : -1; $data['message'] = $result ? '文章置顶成功' : '文章置顶失败'; echo json_encode($data); } public function actionPostOriginal() { $aid = $_GET['aid']; if (empty($aid) || !is_numeric($aid)) { $data['result'] = -2; $data['message'] = '非法请求'; exit; } $post = Post::model()->findByPk($aid); $post->isoriginal = (int)abs($post->isoriginal - 1); $result = $post->update(); $data['result'] = $result ? $post->isoriginal : -1; $data['message'] = $result ? '文章设置为原创' : '文章设置为非原创'; echo json_encode($data); } public function actionUserState() { $uid = $_GET['uid']; if (empty($uid) || !is_numeric($uid)) { $data['result'] = -2; $data['message'] = '非法请求'; exit; } $user = User::model()->findByPk($uid); $user->isvalid = (int)abs($user->isvalid - 1); $result = $user->update(); $data['result'] = $result ? $user->isvalid : -1; $data['message'] = $result ? '更改用户状态成功' : '更改用户状态失败'; echo json_encode($data); } public function actionAdValid() { $aid = $_GET['aid']; if (empty($aid) || !is_numeric($aid)) { $data['result'] = -2; $data['message'] = '非法请求'; exit; } $ad = Advertisement::model()->findByPk($aid); $ad->isvalid = (int)abs($ad->isvalid - 1); $result = $ad->update(); $data['result'] = $result ? $ad->isvalid : -1; $data['message'] = $result ? '广告激活' : '广告禁用'; echo json_encode($data); } public function actionFriendLinkValid() { $fid = $_GET['fid']; if (empty($fid) || !is_numeric($fid)) { $data['result'] = -2; $data['message'] = '非法请求'; exit; } $link = FriendLink::model()->findByPk($fid); $link->isvalid = (int)abs($link->isvalid - 1); $result = $link->update(); $data['result'] = $result ? $link->isvalid : -1; $data['message'] = $result ? '友情链接激活' : '友情链接禁用'; echo json_encode($data); } public function actionTopicValid() { $tid = $_GET['tid']; if (empty($tid) || !is_numeric($tid)) { $data['result'] = -2; $data['message'] = '非法请求'; exit; } $t = Topic::model()->findByPk($tid); $t->isvalid = (int)abs($t->isvalid - 1); $result = $t->update(); $data['result'] = $result ? $t->isvalid : -1; $data['message'] = $result ? '显示主题' : '隐藏主题'; echo json_encode($data); } public function actionCategoryShow() { $cid = $_GET['cid']; if (empty($cid) || !is_numeric($cid)) { $data['result'] = -2; $data['message'] = '非法请求'; exit; } $c = Category::model()->findByPk($cid); $c->isshow = (int)abs($c->isshow - 1); $result = $c->update(); $data['result'] = $result ? $c->isshow : -1; $data['message'] = $result ? '显示分类' : '隐藏分类'; echo json_encode($data); } public function actionCategoryValid() { $cid = $_GET['cid']; if (empty($cid) || !is_numeric($cid)) { $data['result'] = -2; $data['message'] = '非法请求'; exit; } $c = Category::model()->findByPk($cid); $c->isvalid = (int)abs($c->isvalid - 1); $result = $c->update(); $data['result'] = $result ? $c->isvalid : -1; $data['message'] = $result ? '显示分类' : '隐藏分类'; echo json_encode($data); } public function actionCommentShow() { $cid = $_GET['cid']; if (empty($cid) || !is_numeric($cid)) { $data['result'] = -2; $data['message'] = '非法请求'; exit; } $c = Comment::model()->findByPk($cid); $c->isshow = (int)abs($c->isshow - 1); $result = $c->update(); $data['result'] = $result ? $c->isshow : -1; $data['message'] = $result ? '显示分类' : '隐藏分类'; echo json_encode($data); } public function actionCommentRecommend() { $cid = $_GET['cid']; if (empty($cid) || !is_numeric($cid)) { $data['result'] = -2; $data['message'] = '非法请求'; exit; } $c = Comment::model()->findByPk($cid); $c->recommend = (int)abs($c->recommend - 1); $result = $c->update(); $data['result'] = $result ? $c->recommend : -1; $data['message'] = $result ? '显示分类' : '隐藏分类'; echo json_encode($data); } }